#include <iostream>
#include "Channel.h"

int main()
{
    Channel<int> ch(0);

    std::thread producer([&]()
    {
        for(int i = 0; i < 5; ++i)
        {
            ch.Send(i);
            std::cout << "Sent: " << i << std::endl;
        }

        ch.Close();
    });

    std::thread consumer([&]()
    {
        std::this_thread::sleep_for(std::chrono::milliseconds(500));
        int val;
        while(ch.Receive(val))
        {
            std::cout << "Received: " << val << std::endl;
        }
    });

    producer.join();
    consumer.join();
    return 0;
}